package cn.outsourcing.supermarket.controller.backstage;

import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.dto.OnlyIdPayloadDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageNoticeUpdateDTO;
import cn.outsourcing.supermarket.service.HiolabsNoticeService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author gzkemays
 * @since 2021/11/5 4:01
 */
@RestController
@RequestMapping("/admin/notice")
public class NoticeController {
  @Resource HiolabsNoticeService noticeService;

  @PostMapping("/update")
  public Result update(@RequestBody BackstageNoticeUpdateDTO dto) {
    return ResultUtils.simpleResult(noticeService.updateNotice(dto));
  }

  @PostMapping("/add")
  public Result add(@RequestBody BackstageNoticeUpdateDTO dto) {
    return ResultUtils.simpleResult(noticeService.addNotice(dto));
  }

  @PostMapping("/destory")
  public Result add(@RequestBody OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(noticeService.deleteNotice(dto));
  }
}
